package com.wjm.demo.test1.net_test.udp_socket_test.test;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UDPSend {
    public static void main(String[] args) throws Exception {
        DatagramSocket ds = new DatagramSocket();
        String str = "我的天，我发消息了";
        byte[] bytes = str.getBytes();
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, InetAddress.getByName("192.168.0.101"), 10000);//发给1111端口
        ds.send(dp);
        ds.close();
    }
}
